package com.cxz.study.domain.order.orderId;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @className: OrderIdMapper
 * @author: ocxz1
 * @date: 2025/6/15 下午9:18
 * @Version: 1.0
 * @description: ddd-struct3
 */
@Mapper
public interface OrderIdMapper {
    OrderIdMapper INSTANCE = Mappers.getMapper(OrderIdMapper.class);

    // String → OrderId
    @Mapping(target = "value", source = "id")
    OrderId toOrderId(String id);

    // OrderId → String
    default Long toId(OrderId orderId) {
        return orderId != null ? orderId.getValue() : null;
    }
}


